package com.vcaresolution.logistic.controller;

import javax.validation.Valid;

import org.springframework.stereotype.Controller;
import org.springframework.validation.BindingResult;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;

import com.vcaresolution.logistic.form.LoginForm;
import com.vcaresolution.logistic.util.ApplicationConstants;

/**
 * <code>HomeController</code> is used to handle all Home related activity
 *
 * @author Snehal Shah
 * @version 1.0
 * @since ShipSoft 1.0
 */
@Controller
@RequestMapping(value=ApplicationConstants.HOME_URL)
public class HomeController {
	
	/**
	 * This method is called when the GET request has been made to the controller
	 */
	@RequestMapping(method = RequestMethod.GET)
	public void loadPage() {
	}
	
	/**
	 * This method is called when the POST request has been made to the controller
	 */
	@RequestMapping(method = RequestMethod.POST)
	public String processRequest(@Valid LoginForm loginForm, BindingResult result) {
		String view = null;
		
		if( !result.hasErrors() ){
			view = ApplicationConstants.HOME_VIEW;
		}
		
		return view;
	}
}